import request from "../../utils/request"
Page({
  data: {
    proInfoList: [],
    proInfo: {},
    bannerList : [],
    recommentProList:[]
  },
  // 页面开始加载 就会触发
  onLoad: function (options) {

    this.getProInfoAll();
    this.getBanner();
    this.getRecommendPro();
  },
  async getRecommendPro(){
    let ProData =  await request("/cli/hot")
    this.setData({
      recommentProList : ProData.data
    })
  },
  async getProInfoById(){
    let ProData =  await request("/cli/showpro", {id: 1})
    this.setData({
      proInfo : ProData.data
    })
  },
  toRecommendSong(){
      wx.navigateTo({
        url: '/pages/recomment/recomment',
      })
  },
  async getBanner(){
    let bannerData =  await request("/banner/info", {start: 0,num: 10})
    this.setData({
      bannerList : bannerData.data
    })
  },
  toDingcan(){
    wx.navigateTo({
      url: '/pages/category/category',
    })
  },
  toProDetail(event){
    let id = event.currentTarget.dataset.prodid
    wx.navigateTo({
      url: '/pages/pro/pro?id=' + id,
    })
  },
  async getProInfoAll(){
    let ProData =  await request("/cli/showpro/all")
    this.setData({
      proInfoList : ProData.data
    })
  }
})
